<script>
    let p = new Promise((resolve,reject)=>{
        // resolve()
        reject('错误')
    })
    .then(()=>{
        console.log(123);
        
    })
    .catch(e=>{
        console.log(e);
        
    })

    // all race

    //all就是并发


    let p2 = new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve("p2")
        },2000)
    })
    let p3 = new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve("p3")
        },3000)
    })
    let p4 = new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve("p4")
        },4000)
    })

    // Promise.all([p2,p3,p4]) //等到所有的promise有了结果之后彩执行
    // .then(res=>{
    //     console.log(res);
        
    // })

    //race赛跑 获取最先返回结果的那个promise

    Promise.race([p2,p3,p4])
    .then(res=>{
        console.log(res);
        
    })
</script>